/* Copyright 2001,2002,2003 NAH6
 * All Rights Reserved
 *
 * Parts Copyright DoD, Parts Copyright Starium
 *
 */
#include "celpfilt.h"
#include <assert.h>


void do_zfilt_dynamic16to32(
FILTER  *flt,
fxpt_16 coef[],         /*  2.13 format */
fxpt_16 indata[],       /* 15.0  format */
fxpt_32 outdata[])      /* 16.15 format */
{
  int64 acc;
  int i, j;
  fxpt_32 *memory;
  fxpt_32 *pm;
  fxpt_32 *pc;
  fxpt_32 coef32[11];

  ASSERT(flt->data_length == 60);
  ASSERT(flt->order == 10);

  for (i=0 ; i<11 ; i++)
	  coef32[i]= coef[i];

  memory = flt->memory;


  for (i = 0; i < 60; i++) {

    memory[0] = (fxpt_32)indata[i] << 15;
    acc = 0;

    for (j = 10, pm= memory+10, pc=coef32+10; j ; j--,pm--,pc--) {
      acc += (fxpt_64) *pm * *pc;
      pm[0] = pm[-1];
    }

    acc += (int64)memory[0] * coef32[0];
    //outdata[i] = acc >> 13;
    outdata[i] = fxpt_saturate32_round( acc, 13 );
  }

}
